<template>
	<view class="login">
		<Hearder :name="'登录'"></Hearder>
		<image :src="login_img" mode="widthFix"></image>
		<view class="content">
			<view class="login-title">登录/注册</view>
			<view class="itemList">
				<view>账号</view>
				<input type="text" placeholder="请输入登录账号" placeholder-style="color:#999" v-model="phone"/>
			</view>
			<view class="itemList">
				<view>密码</view>
				<input type="password" placeholder="请输入登录密码" placeholder-style="color:#999" v-model="password" style="margin-left: 60rpx;width: 72%;"/>
			</view>
			<view class="itemList">
				<view>空间号</view>
				<input type="text" placeholder="请输入空间号" placeholder-style="color:#999" v-model="space_number" style="margin-left: 60rpx;width: 72%;"/>
			</view>
			<view class="mimall" @click="toPage('xgpassword?type=1')">忘记密码</view>
			<view class="clickdl" @click="phonelogin">登录</view>
			<view class="clickdl zulogin" @click="toPage('register')">注册</view>
			<view class="agent">
				<u-checkbox-group class="kuang" :show="checked" placement="column" @change="checkboxChange">
					<u-checkbox activeColor="#F03D2F" inactiveColor="#999" size="17"></u-checkbox>
				</u-checkbox-group>
				<view class="xy_con">
					<text class="xieyi">同意</text>
					<text @click="toPage('userserver?ll='+3)">《认证服务条款》</text>
					<text @click="toPage('userserver?ll='+2)">《用户隐私协议》</text>
					<text @click="toPage('userserver?ll='+1)">《服务协议》</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				phone:'',
				password:'',
				space_number:'',
				checked:false,
				login_img:''
			}
		},
		onLoad() {
			this.request('/index/getStoreSystem').then(res => {
				if(res.data.code==1){
					this.login_img = res.data.data.login_img
				}
			})
		},
		methods:{
			checkboxChange(e) {
				if(e.length){
					this.checked = true
				}else{
					this.checked = false
				}
			},
			phonelogin(){
				if(!this.checked){
					this.$tip("请先同意协议")
					return
				}
				var that=this
				this.request('/member/login',{
					phone:this.phone,
					password:this.password,
					space_number:this.space_number
				}).then(res => {
					if(res.data.code==1){
						uni.setStorageSync('TOKEN',res.data.data.token);
						uni.setStorageSync('space_id',res.data.data.space_id);
						uni.switchTab({
							url:'/pages/index/index'
						})
					}else{
						this.$tip(res.data.msg)
					}	
				})
			},
			toPage(route){
				uni.navigateTo({
				    url: route
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.login{
		position: relative;
		/deep/ .head{
			background: transparent;
		}
		>image{
			width: 100%;
		}
		.content{
			position: absolute;
			width: 100%;
			height: 100%;
			top: 0;
			text-align: center;
			padding: 0 10%;
			box-sizing: border-box;
			.login-title{
				font-size: 50rpx;
				font-weight: 800;
				margin-top: 210rpx;
			}
			.itemList{
				display: flex;
				align-items: center;
				overflow: hidden;
				border-bottom: 1rpx solid #ffa6a6;
				height: 70rpx;
				margin-top: 60rpx;
				padding-bottom: 10rpx;
				view{
					width: 15%;
				}
				input{
				  width: 78%;
				  height: 80%;
				  margin-left: 64rpx;
				  margin-top: 2rpx;
				}
			}
			.mimall{
				font-size: 28rpx;
				color: #666;
				text-align: right;
				margin: 20rpx 0 50rpx;
			}
			.clickdl{
				height: 90rpx;
				text-align: center;
				line-height: 90rpx;
				background: $uni-item-color;
				margin-bottom: 20rpx;
				color: #fff;
				box-sizing: border-box;
			}
			.zulogin{
				color: $uni-item-color;
				border: 2rpx solid $uni-item-color;
				background: transparent;
			}
			.agent{
				width: 106%;
				margin-left: -3%;
				display: flex;
				justify-content: center;
				align-items: flex-start;
				margin-top: 80rpx;
				/deep/.u-checkbox{
					margin-top: 6rpx;
				}
				/deep/.u-checkbox__icon-wrap--square{
					border-radius: 0;
				}
				.xy_con{
					margin-left: 10rpx;
					text{
						font-size: 24rpx;
					}
					.xieyi{
						color: #999;
					}
				}
			}
		}
	}
</style>